package com.supreme.stockserver.feignapi;

import com.supreme.common.entity.CreateOrder;
import com.supreme.common.dto.StorageToOrder;
import com.supreme.stockserver.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "feign_order")
public class OrderFeignApi {

    @Resource
    private OrderService orderService;

    @PostMapping(value = "create")
    public CreateOrder createOrder(@RequestBody StorageToOrder bodyData) {
        final Long userId = bodyData.getUserId();
        final Long goodsId = bodyData.getGoodsId();
        final Integer goodsNum = bodyData.getGoodsNum();
        return orderService.processSaleOrder(userId, goodsId, goodsNum);
    }
}
